/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

Ext.QuickTips.init();
var _pageSize = 20;

var fieldName = ['id', 'deviceNo', 'modelId', 'adminAreaCode', 'installSite', 'mobileNo', 'uniqueCode', 'pointId', 'pointName', 'runTime', 'checkTime', 'expireTime', 'status',
    'note', 'updateTime', 'createTime', 'orgCode', 'model', 'commTypeName', 'manufactoryName', 'produceTime', 'channel', 'zbm', 'company', 'subCompany', 'shortName',
    'pointType', 'pointType2', 'pointName', 'terminalNo', 'reportNo', 'result', 'remark', "realName", 'checkTime'];
var fieldLabel = ['ID', '设备编号', '终端型号ID', '区域码', '安装地点', '手机号码', '唯一码', '监测点ID', '监测点名称', '投运日期', '检测日期', '有效期', '状态',
    '备注', '更新日期', '创建日期', '机构编码', '型号', '通信方式', '生产厂家', '出厂日期', '通道', '组编码', '供电局', '部门分县局', '供电所',
    '监测点类型', '电网类型', '监测点名称', '终端编号', '报告编号', '检验结果', '评价', '校验人'];

var loadServlet = basePath + 'servlet/point/CheckHistoryLoad';

var theme = '装置校验';

var _title = currentOrgName + theme + '历史查询';

var now = new Date();
var dayFrom = now.add(Date.DAY, -30);
var dayTo = now;

var store;
function buildWindow() {
    store = new Ext.data.JsonStore({
        url: loadServlet,
        root: 'data',
        idProperty: 'id',
        totalProperty: 'count',
        fields: fieldName
        , baseParams: {dayFrom: dayFrom.format('Y-m-d'), dayTo: dayTo.format('Y-m-d'), start: 0, limit: _pageSize}
        , autoLoad: true
    });

    var grid = new Ext.grid.GridPanel({
        title: _title,
        store: store,
        columns: [
            {header: fieldLabel[0], sortable: true, dataIndex: fieldName[0], hidden: true},
            {header: '供电局', width: 100, sortable: true, dataIndex: 'company'},
            {header: '部门分县局', width: 100, sortable: true, dataIndex: 'subCompany'},
            {header: '供电所', width: 100, sortable: true, dataIndex: 'shortName'},
            {header: '监测点名称', width: 100, sortable: true, dataIndex: 'pointName'},
            {header: '终端编号', width: 80, sortable: true, dataIndex: 'terminalNo'},
            {header: '区域码', width: 100, sortable: true, dataIndex: 'adminAreaCode'},
            {header: '组编码', width: 100, sortable: true, dataIndex: 'zbm'},
            {header: '有效期', width: 80, sortable: true, dataIndex: 'expireTime', xtype: 'datecolumn', format: 'Y-m-d'},
            {header: '报告编号', width: 80, sortable: true, dataIndex: 'reportNo'},
            {header: '检验结果', width: 100, sortable: true, dataIndex: 'result'},
            {header: '安装地点', width: 80, sortable: true, dataIndex: 'installSite'},
            {header: '型号', width: 80, sortable: true, dataIndex: 'model'},
            {header: '生产厂家', width: 100, sortable: true, dataIndex: 'manufactoryName'},
            {header: '投运日期', width: 80, sortable: true, dataIndex: 'runTime', xtype: 'datecolumn', format: 'Y-m-d'},
            {header: '出厂日期', width: 80, sortable: true, dataIndex: 'produceTime', xtype: 'datecolumn', format: 'Y-m-d'},
            {header: '校验人', width: 80, sortable: true, dataIndex: 'realName'},
            {header: '校验日期', width: 80, sortable: true, dataIndex: 'checkTime'},
            {header: '备注', width: 80, sortable: true, dataIndex: 'note'},
            {header: '设备编号', width: 80, sortable: true, dataIndex: 'deviceNo'},
            {header: '通信方式', width: 80, sortable: true, dataIndex: 'commTypeName'},
            {header: '监测点类型', width: 80, sortable: true, dataIndex: 'pointType'},
            {header: '电网类型', width: 80, sortable: true, dataIndex: 'pointType2'}
        ],
        loadMask: true,
        tbar: new Ext.Toolbar([
            {text: '检验日期：', xtype: 'label'},
            {
                xtype: 'datefield',
                id: 'DayFrom',
                value: dayFrom,
                format: 'Y年m月d日',
                width: 150,
                listeners: {
                    select: function(c, date) {
                        store.baseParams.dayFrom = date.format('Y-m-d');
                    }
                }
            },
            {text: '至', xtype: 'label'},
            {
                xtype: 'datefield',
                id: 'DayTo',
                value: dayTo,
                format: 'Y年m月d日',
                width: 150,
                listeners: {
                    select: function(c, date) {
                        store.baseParams.dayTo = date.format('Y-m-d');
                    }
                }
            }, {
                xtype: 'textfield',
                name: 'pointName',
                emptyText: '输入检测点名称'
                , id: 'PointName'
            },
            {text: '搜索', iconCls: 'icon-search', handler: function() {
                    store.baseParams.pointName = Ext.getCmp('PointName').getValue();
                    store.reload()
                }}

        ]),
        bbar: new Ext.PagingToolbar({
            pageSize: _pageSize,
            store: store,
            displayInfo: true,
            displayMsg: '显示记录：{0} - {1}   总记录：{2}',
            emptyMsg: "目前没有" + theme + '信息'
        })
    });

    var applicationUI = new Ext.Viewport({
        layout: "fit",
        items: [
            grid
        ]
    });
}
Ext.onReady(buildWindow);
